package com.oneandseven.dajia.base.service.impl;

import com.oneandseven.dajia.base.entity.BaseEntity;
import com.oneandseven.dajia.base.repository.IBaseRepository;
import com.oneandseven.dajia.base.service.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.Repository;

import java.util.List;

public class BaseService<E extends BaseEntity, R extends IBaseRepository<E>> implements IBaseService<E> {

    @Autowired
    protected R repository;


    public E queryOne(String id) {
        return this.repository.findById(id).orElse(null);
    }

    public List<E> queryAll() {
        return this.repository.findAll();
    }

}
